package com.neouton.common.util;

import com.alibaba.fastjson.JSONObject;
import com.neouton.crm.entity.NoticVo;
import com.neouton.feginClient.FeginMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.sql.Timestamp;

@Component
public class NoticUtils {

    @Autowired
    private FeginMessageService feginMessageService;

    @Autowired
    private static FeginMessageService staticFeginMessageService;

    @PostConstruct
    public void init() {
        staticFeginMessageService = feginMessageService;
    }

    public static JSONObject pushNotic(Integer workflowId, Timestamp askTime, Integer askUserId,
                                       Integer workState, Integer taskType, Integer todoUserId, String token){
        NoticVo vo = new NoticVo();
        vo.setFromSystem("crm");
        vo.setWorkflowId(workflowId);
        vo.setAskUserId(askUserId);
        vo.setAskTime(askTime);
        vo.setWorkState(workState);
        vo.setTaskType(taskType);
        vo.setTodoUserId(todoUserId);
        return staticFeginMessageService.pushNoticToDB(token,vo);
    }

    public static JSONObject pushNotics(Integer workflowId, Timestamp askTime, Integer askUserId,
                                       Integer workState, Integer taskType, Integer todoUserId, String token){
        NoticVo vo = new NoticVo();
        vo.setFromSystem("crm");
        vo.setWorkflowId(workflowId);
        vo.setAskUserId(askUserId);
        vo.setAskTime(askTime);
        vo.setWorkState(workState);
        vo.setTaskType(taskType);
        vo.setTodoUserId(todoUserId);
        return staticFeginMessageService.pushNoticToDB(token,vo);
    }
}
